Skip to content

Conversation

@koppor
Copy link
Member

@koppor koppor commented Nov 6, 2025

Strongly demanded by the community. Was available inside JabRef; now we can offer as CLI.

Kind of follow-up to #14233.

We use CrossRef

Steps to test

Create and modify debug configuration for org.jabref.JabKit#main

image

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • [/] I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

@koppor koppor requested a review from subhramit November 6, 2025 23:20
@palukku
Copy link
Member

palukku commented Nov 7, 2025

I tried running it with a valid and an completely invalid doi 1234test as two arguments and it threw an error:

Unmatched argument at index 2: '1abref'
Usage: jabkit doi-to-bibtex DOI...
Converts a DOI to BibTeX
      DOI...   one or more DOIs to fetch

But I would say it should not completely "crash" but print out the valid one and for the second the Could not fetch DOI from BibTeX.

Copy link
Member

@subhramit subhramit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Micro comments - I am committed to not letting vars enter again - so keeping them only in the example file


@Override
public Integer call() {
var fetcher = new CrossRef();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var fetcher = new CrossRef();
CrossRef fetcher = new CrossRef();

Comment on lines +58 to +60
try (var writer = new OutputStreamWriter(System.out, StandardCharsets.UTF_8)) {
var context = new BibDatabaseContext(new BibDatabase(entries));
var bibWriter = new BibDatabaseWriter(writer, context, argumentProcessor.cliPreferences);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try (var writer = new OutputStreamWriter(System.out, StandardCharsets.UTF_8)) {
var context = new BibDatabaseContext(new BibDatabase(entries));
var bibWriter = new BibDatabaseWriter(writer, context, argumentProcessor.cliPreferences);
try (OutputStreamWriter writer = new OutputStreamWriter(System.out, StandardCharsets.UTF_8)) {
BibDatabaseContext context = new BibDatabaseContext(new BibDatabase(entries));
BibDatabaseWriter bibWriter = new BibDatabaseWriter(writer, context, argumentProcessor.cliPreferences);

@palukku
Copy link
Member

palukku commented Nov 7, 2025

And maybe also a option which disables the error messages but still returns exit code 1, so if you want to work with the output and ignore errors for example. Can't name a case for that, but i can imagine that it could be helpful.

But one could probably just read the out and ignore err output and achieve it without the extra option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants